package com.eternal.permission.entity.enums;

import com.baomidou.mybatisplus.enums.IEnum;

import com.fasterxml.jackson.annotation.JsonValue;

import java.io.Serializable;

/**
 * 是否打开枚举
 *
 * @author Eternal
 * @Title: IsOpenEnum
 * @ProjectName notest
 * @Description: TODO
 * @date 2018/9/6 15:14
 */
public enum IsOpenEnum implements IEnum {

    OPEN("1", "开启"),
    CLOSE("0", "关闭");

    private String code;
    private String name;


    IsOpenEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }



    @JsonValue
    public String getName() {
        return name;
    }

   /* @Override
    public IsOpenEnum getEnumByCode(String code) {
        return null;
    }
*/


   public static IsOpenEnum getEnumByCode(String code) {

        for (IsOpenEnum ftype : IsOpenEnum.values()) {
            if (ftype.code.equals(code)) {
                return ftype;
            }
        }
        return null;
    }

    public static IsOpenEnum getEnumByDescribe(String Describe) {

        for (IsOpenEnum ftype : IsOpenEnum.values()) {
            if (ftype.name.equals(Describe)) {
                return ftype;
            }
        }
        return null;
    }

    @Override
    public Serializable getValue() {
        return this.code;
    }
}
